package com.dubbo.provider.config;

import com.dubbo.provider.entity.Invocation;
import com.dubbo.provider.tomcat.TomcatServer;
import com.dubbo.provider.util.HttpClient;
import com.dubbo.provider.util.Url;

import java.io.IOException;

/**
 * @description: http协议
 * @author: 石亚宁
 * @create: 2020-05-29 13:38
 **/

public class DubboProtocol implements Protocol {
	@Override
	public void start(Url url) {
		try {
			new TomcatServer().start(url.getPath(),url.getPort());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public Object send(Url url, Invocation invocation) {
		try {
			return new HttpClient().send(url.getPath(),url.getPort(),invocation);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
